package com.pda.gongpin.presenter;

import com.pda.gongpin.bean.ScanResultBean;
import com.pda.gongpin.bean.SkuBean;
import com.pda.gongpin.bean.SkuListBean;
import com.pda.gongpin.bean.request.EntryNoRequest;
import com.pda.gongpin.bean.request.QRcodeRequest;
import com.pda.gongpin.bean.request.ShelvesRequest;
import com.pda.gongpin.contract.FullTrayInContract;
import com.pda.gongpin.contract.FullTrayInNewContract;
import com.pda.gongpin.net.NetUtils;
import com.wangshen.base.net.bean.BaseAppEntity;
import com.wangshen.base.ui.mvp.base.presenter.BasePresenter;

import java.util.List;

import io.reactivex.functions.Consumer;

public class FullTrayInNewPresenter extends BasePresenter<FullTrayInNewContract.View> implements FullTrayInNewContract.Presenter{

    @Override
    public void getSkuList(String body) {
        NetUtils.geApi().getSkuList(body)
                .compose(this.handleEverythingResult())
                .subscribe(new Consumer<BaseAppEntity<List<SkuListBean>>>() {
                    @Override
                    public void accept(BaseAppEntity<List<SkuListBean>> listBaseAppEntity) throws Exception {
                        getView().setList(listBaseAppEntity.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        getView().showMessage(throwable.getMessage());
                    }
                });
    }

    @Override
    public void shelves(String entryNumberId, String workStorageBinId, String container, String number) {
        NetUtils.geApi().shelves(entryNumberId, workStorageBinId, container, number)
                .compose(this.handleEverythingResult())
                .subscribe(new Consumer<BaseAppEntity<List<SkuListBean>>>() {
                    @Override
                    public void accept(BaseAppEntity<List<SkuListBean>> listBaseAppEntity) throws Exception {
                        getView().showMessage(listBaseAppEntity.getMessage());
                        getView().finishActivity();
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        getView().showMessage(throwable.getMessage());
                    }
                });
    }
}
